/****************************************************
          File Name:msgsnd.c
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Thu 11 Sep 2014 10:26:28 AM CST
*****************************************************/

#include"msg.h"
#include<string.h>

int main(int argc,char *argv[])
{
    int status;
    struct msgbuf msgp;

    if(argc<4)
    {
        printf("%s msgid mtype mtext\n",argv[0]);
        exit(1);
    }

    msgp.mtype=atol(argv[2]);
    memcpy(msgp.mtext,argv[3],strlen(argv[3]));

    status=msgsnd(atoi(argv[1]),&msgp,DATA_SIZE,IPC_NOWAIT);
    if(status==-1)
        err("msgsnd");

    return 0;
}
